import request from '../utils/request'
import API from './constants'

/**
 * 分页查询列表数据
 */
export const getList = ({page = 1, pageSize = 10} = {}) => request({
  url: API.HEALTH_API,
  method: 'GET',
  params: {
    page,
    pageSize
  }
})

/**
 * 查询所有数据
 */
export const getAll = () => request({
  url: API.HEALTH_API,
  method: 'GET',
  params: {
    action: 'all'
  }
})

/**
 * 添加健康数据
 * @param {*} info 数据项信息
 */
export const add = info => request({
  url: API.HEALTH_API,
  method: 'POST',
  data: info
})

/**
 * 修改健康数据
 * @param {*} info 数据项信息
 */
export const update = info => request({
  url: API.HEALTH_API + '/' + info.id,
  method: 'PUT',
  data: info
})

/**
 * 删除健康数据
 * @param {*} id
 */
export const remove = id => request({
  url: API.HEALTH_API + '/' + id,
  method: 'DELETE'
})
